<template>
  <n-config-provider class="min-h-screen" :theme="currentTheme">
    <AppProvider>
      <router-view />
    </AppProvider>
  </n-config-provider>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia'
import AppProvider from '@/components/AppProvider/index.vue'
import { useAppStore } from '@/stores'

export default defineComponent({
  name: 'App',
  components: {
    AppProvider
  },
  setup() {
    const route = useRoute()
    const appStore = useAppStore()

    const { currentTheme } = storeToRefs(appStore)

    // tailwindcss dark模式
    if (currentTheme.value.name === 'dark') {
      document.documentElement.classList.add('dark')
      window.ipcRenderer.send('set-theme', 'dark')
    }

    window.ipcRenderer.send(
      'batch-schedule',
      JSON.parse(JSON.stringify(appStore.remind))
    )

    return {
      route,
      currentTheme
    }
  }
})
</script>

<style lang="scss">
@use '@/styles/common';
@use '@/styles/public';
</style>
